/**
 * Copyright (C), 2020, Y2 T205
 * FileName: GulimallElasticSearchConfig
 * Author: Lenovo
 * Date: 2020-05-18 20:42
 * Description:
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */


package com.atguigu.gulimall.search.config;


import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sound.sampled.Port;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 *
 * @author Lenovo
 * @create 2020-05-18
 * @since 1.0.0
 */
@Configuration
public class GulimallElasticSearchConfig {

    public static final RequestOptions COMMON_OPTIONS;
    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
//        builder.addHeader("Authorization", "Bearer " + TOKEN);
//        builder.setHttpAsyncResponseConsumerFactory(
//                new HttpAsyncResponseConsumerFactory
//                        .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
        COMMON_OPTIONS = builder.build();
    }


    @Bean
   public RestHighLevelClient esRestClient(){
       RestClientBuilder builder=null;
       //
     builder=  RestClient.builder(new HttpHost(new HttpHost("192.168.64.132",9200,"http")));

       RestHighLevelClient client = new RestHighLevelClient(builder);
       return client;
   }


}
